<template>
	<view :style="{height:getInfo,'background':'#fff'}">
		<view v-if="param.name=='地址'" class="ditu">
			<map style="width:100%;height:100%;" 
				:latitude="latitude"
				:longitude="longitude"
				:scale="scale"
				:markers="marker"
				@markertap="toMap()">
			</map>
			<view class="toMap publicButton" @click="toMap">一键导航</view>
		</view>
		<view v-else>
			<view class="phone">{{telephone}}</view>
			<view class="toMap publicButton" style="bottom:100px" @click="phoneHandle">一键拨号</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Height:0,//页面高度
				param:{},//接受参数
				latitude: 23.01459,
				longitude: 113.09687,
				marker: [{
					id: 0,
					latitude: 23.01459,
					longitude: 113.09687,
					title: '佛山易租云科技有限公司', //标注点名
				}],
				scale: 14, //地图缩放程度
				telephone:'13413345432'
			};
		},
		computed:{
			getInfo(){//获取设备信息
				let info=uni.getSystemInfoSync()
				return info.windowHeight + 'px'
			},
		},
		methods:{
			toMap(){
				uni.openLocation({
					latitude: Number(this.latitude), //要去的纬度-地址
					longitude: Number(this.longitude), //要去的经度-地址
					name:'佛山易租云科技有限公司',
					address: '广东省佛山市禅城区季华四路佛山创意产业园23栋636室',   //要去的具体地址
				});
			},
			phoneHandle(){
				uni.makePhoneCall({
					phoneNumber: this.telephone,
					// 失败回调
					fail: (res) => {
						console.log(res)
					}
				})
			},
		},
		onLoad(options) {
			this.param=options
			if(this.param.name=='手机'){
				this.phoneHandle()
			}else{
				this.toMap()
			}
			
		}
	}
</script>

<style lang="scss" scoped>
.ditu {
	width: 100%;
	height: 85%;
}
.toMap{
	background:#2BA245 !important;
}
.phone{
	font-size:30px;
	font-weight: 800;
	text-align: center;
	padding:30px;
}
</style>
